#include "gf_int.h"

#include <sys/time.h>
#include <stdlib.h>

void
timer_start (double *t)
{
    struct timeval  tv;

    gettimeofday (&tv, NULL);
    *t = (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
}

double
timer_split (const double *t)
{
    struct timeval  tv;
    double  cur_t;

    gettimeofday (&tv, NULL);
    cur_t = (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
    return (cur_t - *t);
}

void
galois_fill_random (void *buf, int len, unsigned int seed)
{
    int     i;

    if (seed != 0) {
        srandom (seed);
    } else {
        srandom(10);
		//srandomdev ();
    }

    for (i = 0; i < len; i += 4) {
        *(uint32_t *)(buf + i) = random ();
    }
    if (len % 4 != 0) {
        *(uint32_t *)(buf + len - 4) = random ();
    }
}
